% function to set defaults for
% ts processing
% In future this need to be changed to a GUI dialogue box
% Any new entry can be made to the structure ProcDef
% However NO ENRTY/FIELD SHOULD BE deleted from ProcDef

%latest date 16.06.2003

function[ProcDef] = SetDefault(nband),

ProcDef.ref = 0; % remote reference, keep ref = 1 for rr. 0 otherwise

% Be careful about changing channel number, equations, array etc
% as it is used by many functions
ProcDef.Array    = [4 5 1 2 3 6 7]; % EDI standard PL DO NOT CHANGE
ProcDef.sensor   = [1 2 3 4 5 3 4]; % Ex Ey Hx Hy Hz Hxr Hyr channel number;
ProcDef.notchdef = [1 1 1 1 1 2 2]; % stite1 & site2 notch used in getspectra.m
												% Also used in rrcorrectts.m as 
												% ProcDef.sensor(find(ProcDef.notchdef==2)) To pack the remote m filed to 
ProcDef.equations = [4 1 2;5 2 1];  % defining bi-variate eqns                  Local spec change here
ProcDef.rreqn = [4 1 2 6 7;5 1 2 6 7]; % eqn for rr processing                  default = [1 1 1 1 1 2 2];
ProcDef.neq = 2; % number of equtions defined
% -------------------------------------------------------------------

ProcDef.PAI = 3.1415926535897; % is it needed ?
ProcDef.MaxVal = 1.0E+6;  % Value(s) to scale SPMatrices
ProcDef.MinVal = 1.0E-6;
ProcDef.ScaleVal = 1.0E+4;
ProcDef.RadSize = [0.125 0.25 0.5 0.75];   % size of Parzen window
%ProcDef.RadSize = [0.025 0.25 0.5 0.75];   % size of Parzen window
ProcDef.RdBd    = [2 1 3 3 3];	% rad size for bands % band4 changed to 1 17.6.3
ProcDef.GMS05.fs = [32768 1024 32 1 1/32]; % samplig rate gms05 bands
selblock =  [128;256;512;1024;2048;4096]; 
mychoice = [1024;1024;1024;1024;1024]; % this overrides the user menu selection 
% str = {'128','256','512','1024','2048','4096'};
% [s,v] = listdlg('PromptString','Select nfft:',...
% 'SelectionMode','single',...
% 'ListSize',[100 50],'ListString',str); % prompting user to set a block size
% if v == 0,
%  return;
% end;
% if nband <3 & s>4,
%    s=4;
% end;


ProcDef.block = mychoice(nband); 
ProcDef.annthreshold = 0.6; % ANN slection threshold (applicable to band 4)
ProcDef.DoANN = 0; % 1 ANN selection ON; 0 OFF

ProcDef.Method = 'RB'; %LS - Least Square; RB - Robust M; JK - Jack Knife; CO - Coherencies; CT Coherency Treshold
% Selection of averaging methods
ProcDef.BandAv = 'R'; % R - Robust band averaging P = parzen averaging

ProcDef.CohTr = 0.7;

ProcDef.nband=nband;      % nband comes from invoking program

if nband > 2,
   ProcDef.overlap = 1;  % set to 0 for non overlap of ts
else,
   ProcDef.overlap = 0;  % benad 2 and 1 are slices of ts not continous !
end;

[TLine,TLRad,TLFreq,TBand] = settline(ProcDef.block,ProcDef.RadSize(ProcDef.RdBd)); % target freq, line & radius for all bands
ProcDef.TLine1  = TLine(find(TBand==nband));
ProcDef.TLRad1  = TLRad(find(TBand==nband));
ProcDef.TLRad1(find(ProcDef.TLRad1<4))=4; % ensures min dof
k=find((ProcDef.TLine1-ProcDef.TLRad1)<0);
ProcDef.TLFreq1 = TLFreq(find(TBand==nband));
ProcDef.TLFreq1(k)=[]; % This deletes frequencies with less than 4 harmonics to average
ProcDef.nfrq = length(ProcDef.TLine1)-length(k);
ProcDef.len=0; % number of blocks (nfft) to be set lateron by main program
ProcDef.file1=char([1 12]); % Local station name (to be set by main program)
ProcDef.file2=char([1 12]); % Reomte station name ( ,,           ,,        )
ProcDef.WriteEdi=0;   % 1 writes the Output Spectra in edi format